package core.spring.ext;

import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ResourceUtils;

public class ResourceLoadUtil {
	
	private static ResourceLoader resLoader = new DefaultResourceLoader();

	public static Resource loadResource(String resId) {
		if (resId.startsWith(ResourceUtils.FILE_URL_PREFIX) == false
				&& resId.startsWith(ResourceUtils.CLASSPATH_URL_PREFIX) == false) {
			resId = ResourceUtils.FILE_URL_PREFIX + resId;
		}

		return resLoader.getResource(resId);
	}
}
